package com.jiawa.wiki.controller;

import com.jiawa.wiki.response.CommonResp;
import com.jiawa.wiki.response.StatisticResp;
import com.jiawa.wiki.service.EbookSnapshotService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/ebook-snapshot")
public class EbookSnapshotController {

    @Resource
    private EbookSnapshotService ebookSnapshotService;

    /**
     * 获取今天 昨天统计数据
     * @return
     */
    @GetMapping("/get-statistic")
    public CommonResp getStatistic() {
        CommonResp<List<StatisticResp>> commonResp = new CommonResp<>();
        List<StatisticResp> statistic = ebookSnapshotService.getStatistic();
        commonResp.setContent(statistic);
        return commonResp;
    }

    /**
     * 获取30天统计数据
     * @return
     */
    @GetMapping("/get-30-statistic")
    public CommonResp get30Statistic() {
        CommonResp<List<StatisticResp>> commonResp = new CommonResp<>();
        List<StatisticResp> statistic = ebookSnapshotService.get30Statistic();
        commonResp.setContent(statistic);
        return commonResp;
    }
}
